package org.alex.samples.model;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotEmpty;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;

@Entity
@Table(name="exam_subject")
public class ExamSubject implements Serializable {
	
	private static final long serialVersionUID=-8694539773273501319L;
	
	@Id
	@GeneratedValue
	@Column(name="sub_id")
	@NotNull(message="ID不可以为空！")
	private Integer subId;
	
	@Column(name="name",length=1000,nullable=false)
	@NotEmpty(message="姓名不可以为空！")
	private String name;
	
	@Column(name="description",length=1000,nullable=false)
	private String description;
	
	@Column(name="test_count",length=1000,nullable=false)
	private Integer testCount;
	
	@Column(name="total_time",length=1000,nullable=false)
	private Integer totalTime;
	
	@Column(name="total_score",length=1000,nullable=false)
	private Double totalScore;
	
	@Column(name="status",length=1000,nullable=false)
	private Integer status;
	
	@ManyToMany(cascade={CascadeType.DETACH,CascadeType.PERSIST,CascadeType.MERGE,CascadeType.ALL})
	@JoinTable(name="exam_user_subject",                        //中间表的名称
	joinColumns={@JoinColumn(name="sub_id")},				//本表与中间表的外键对应关系
	inverseJoinColumns={@JoinColumn(name="user_id")})		//另一张表与中间表的外键的对应关系
	private Set<UserJDBC> userJDBC=new HashSet<UserJDBC>();
	
	@OneToMany(mappedBy="examSubject")
	private Set<ManageTest> manageTest;
		
	
	public Set<ManageTest> getManageTest() {
		return manageTest;
	}
	public void setManageTest(Set<ManageTest> manageTest) {
		this.manageTest = manageTest;
	}
	public Integer getSubId() {
		return subId;
	}
	public void setSubId(Integer subId) {
		this.subId = subId;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Integer getTestCount() {
		return testCount;
	}
	public void setTestCount(Integer testCount) {
		this.testCount = testCount;
	}
	public Integer getTotalTime() {
		return totalTime;
	}
	public void setTotalTime(Integer totalTime) {
		this.totalTime = totalTime;
	}
	public Double getTotalScore() {
		return totalScore;
	}
	public void setTotalScore(Double totalScore) {
		this.totalScore = totalScore;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	
	public Set<UserJDBC> getUserJDBC() {
		return userJDBC;
	}
	public void setUserJDBC(Set<UserJDBC> userJDBC) {
		this.userJDBC = userJDBC;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	
	
	public ExamSubject() {
		super();
	}
	
	

	
}
